const express = require('express');
const pro = express.Router();
const pool = require('../pool.js');
// 登陆显示店铺商品的信息
pro.get('/shop/:state', (req, res) => {
    let state;
    console.log(req.params.state);
    if (req.params.state == 1) {
        state = '上架中';
    } else if (req.params.state == 2) {
        state = '审核中';
    } else {
        state = '已下架'
    };
    pool.query('select * from goods where state = ?', [state], (err, r) => {
        if (err) {
            throw err;
        }
        res.send(r);
    })
});
// 订单管理
pro.get('/orders', (req, res) => {
    let order_status = '已完成';
    if (req.query.oid) {
        pool.query('select * from orders where oid = ? and order_status != ?', [req.query.oid, order_status], (err, r) => {
            if (err) {
                throw err;
            }
            res.send(r);
        })
    } else {
        pool.query('select * from orders where order_status != ?', [order_status], (err, r) => {
            if (err) {
                throw err;
            }
            res.send(r);
        })
    }
});
module.exports = pro;
